var pageSize = 10,pageNum = 1,canScroll=false,hpLogin_token = window.localStorage.getItem("hpLogin_token");;

getBargain();

function getBargain(isload){
  $.ajax({
      type:'POST',
      url:address+'/houseDeal/list.do?format=true',
      data:{
        "pageNum":pageNum,
        "pageSize":pageSize,
        "hpLogin_token":hpLogin_token
      },
      dataType:'json',
      success:function(result){
        if(result.status ==200 && result.data.list !=""){
            var html = "";
            $.each(result.data.list,function(index,info){
                html += '<dl class="list p5 b-b db">'+
                '<dt><img src="'+info.image+'" class="pic"></dt>'+
                '<dd>'+
                  '<div class="name l-h20 black">'+info.newBuildingsName+'</div>'+
                  '<p class="black l-h24 m-t5"><span class="fr">'+info.customer+'</span>总价：'+info.price+'万</p>'+
                  '<div class="label gray m-t5">成交时间：'+info.timeStr+'</div>'+
                '</dd>'+
              '</dl>';
            });
            if(isload){
              $("#Bargain").append(html);
            }else{
              $("#Bargain").html(html);
            }
            canScroll =true;
        }else{
          canScroll =false;
          var html = '<div class="nodata">没有数据</div>';
          $("#Bargain").html(html);
        }
      },
      error:function(result){
        message(result.message)
      }
  })
}

//滚动加载
$(window).scroll(function(){
    var scrollT = document.documentElement.scrollTop || document.body.scrollTop,
    clientH = $(window).height(),
    docH = $(document).height();
    var $loading = $(".loading");
    if(scrollT >= (docH - clientH) && canScroll==true){
      canScroll = false;
      pageNum ++;
      $loading.show();
      var isload = true;
      getBargain(isload);

    }else{
      $loading.hide();
    }
})


